package cn.hx.handsetticketinspection.listener;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import cn.hx.handsetticketinspection.base.BaseBean;
import cn.hx.handsetticketinspection.constant.HttpUrls;
import cn.hx.handsetticketinspection.netword.HttpUtils;
import cn.hx.handsetticketinspection.netword.Interfaceabstract.HttpInterface;
import cn.hx.handsetticketinspection.netword.Interfaceabstract.OKHttpListener;
import cn.hx.handsetticketinspection.params.DeviceStateReport;
import cn.hx.handsetticketinspection.utils.Utils;

/**
 * 开机启动完成广播的接收器
 */
public class BootBroadcastReceiver extends BroadcastReceiver implements HttpInterface {

    private static final String ACTION_BOOT = "android.intent.action.BOOT_COMPLETED";
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(ACTION_BOOT)) { // TODO 开机启动完成后，要做的事情

            DeviceStateReport report = new DeviceStateReport();
            report.setStateType("switch");
            report.setStateValue(2);
            HttpUtils.postDefault(this, HttpUrls.basic_deviceStateReport_stateReport,
                    report.toMapUtils(),
                    BaseBean.class, new OKHttpListener<BaseBean>() {
                        @Override
                        public void onSuccess(BaseBean bean) {
                            // Utils.toast(bean.response);
                        }
                    });

        }
    }

    @Override
    public Activity getActivity() {
        return null;
    }

    @Override
    public boolean isDiscardHttp() {
        return true;
    }
}
